package domain.entities;

import javax.persistence.*;
import java.io.File;
import java.util.Date;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * Equipmentcertification entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "equipmentcertification", catalog = "bms")
public class Equipmentcertification implements java.io.Serializable {

	// Fields

	private Integer id;
    private Centro centro;
    private EquipmentType equipmentType;
    private String serialNumber;
    private String location;
    private Date expirationDate;
    private Date lastcalibrationCell;
    private String calibrationFrequency;

    private String certification;
    private File certificationFile;
    private String certificationFileContentType;
    private String certificationFileFileName;


    private byte[] file;
    private String filename;

	// Constructors

	/** default constructor */
	public Equipmentcertification() {
	}

    // Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

    @Temporal(TemporalType.DATE)
	@Column(name = "expirationDate", length = 10)
	public Date getExpirationDate() {
		return this.expirationDate;
	}

	public void setExpirationDate(Date expirationDate) {
		this.expirationDate = expirationDate;
	}

    @OneToOne()
    public Centro getCentro() {
        return centro;
    }

    public void setCentro(Centro centro) {
        this.centro = centro;
    }



    @OneToOne()
    public EquipmentType getEquipmentType() {
        return equipmentType;
    }

    public void setEquipmentType(EquipmentType equipmentType) {
        this.equipmentType = equipmentType;
    }

    @Column(name = "serialnumber")
    public String getSerialNumber() {
        return serialNumber;
    }

    public void setSerialNumber(String serialNumber) {
        this.serialNumber = serialNumber;
    }

    @Column(name = "location")
    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    @Column(name = "certification")
    public String getCertification() {
        return certification;
    }

    public void setCertification(String certification) {
        this.certification = certification;
    }

    @Transient
    public File getCertificationFile() {
        return certificationFile;
    }

    public void setCertificationFile(File certificationFile) {
        this.certificationFile = certificationFile;
    }
    @Transient
    public String getCertificationFileContentType() {
        return certificationFileContentType;
    }

    public void setCertificationFileContentType(String certificationFileContentType) {
        this.certificationFileContentType = certificationFileContentType;
    }
    @Transient
    public String getCertificationFileFileName() {
        return certificationFileFileName;
    }

    public void setCertificationFileFileName(String certificationFileFileName) {
        this.certificationFileFileName = certificationFileFileName;
    }

    @Temporal(TemporalType.DATE)
    @Column(name = "lastcalibrationCell", length = 10)
    public Date getLastcalibrationCell() {
        return lastcalibrationCell;
    }

    public void setLastcalibrationCell(Date lastcalibrationCell) {
        this.lastcalibrationCell = lastcalibrationCell;
    }

    @Column(name = "calibrationFrequency")
    public String getCalibrationFrequency() {
        return calibrationFrequency;
    }

    public void setCalibrationFrequency(String calibrationFrequency) {
        this.calibrationFrequency = calibrationFrequency;
    }

    @Column(name = "file")
    public byte[] getFile() {
        return file;
    }

    public void setFile(byte[] file) {
        this.file = file;
    }

    @Column(name = "filename")
    public String getFilename() {
        return filename;
    }

    public void setFilename(String filename) {
        this.filename = filename;
    }

    @Transient
    public boolean isNew(){
        return this.id == null;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Equipmentcertification)) return false;

        Equipmentcertification that = (Equipmentcertification) o;

        if (!id.equals(that.id)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return id.hashCode();
    }
}